package net.diaowen.dwsurvey.entity;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import net.diaowen.common.base.entity.IdEntity;

/**
 * 抽奖活动
 * @author zhangyuting
 * @date 2019年6月20日
 *
 */
@Entity
@Table(name="t_lottery_activity")
public class LotteryActivity extends IdEntity{
	/**
	 * 问卷id
	 */
	private String surveyId;
	/**
	 * 活动名
	 */
	private String name;
	/**
	 * 活动描述
	 */
	private String description;
	/**
	 * 开始时间
	 */
	private Date startTime;
	private String startTimeStr;
	/**
	 * 结束时间
	 */
	private Date endTime;
	private String endTimeStr;
	/**
	 * 创建时间
	 */
	private Date createTime;
	/**
	 * 创建者
	 */
	private String createUser;
	/**
	 * 更新时间
	 */
	private Date updateTime;
	/**
	 * 更新者
	 */
	private String updateUser;
	/**
	 * 显示flag 0不显示 1显示
	 */
	private int visibility = 0;

	/**
	 * wxQRcode用于存储微信二维码存放路径
	 */
	private String wxQRcode;



	public String getSurveyId() {
		return surveyId;
	}
	public void setSurveyId(String surveyId) {
		this.surveyId = surveyId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Date getStartTime() {
		if (startTime != null) {
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			startTimeStr = formatter.format(startTime);
		}
		return startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	public Date getEndTime() {
		if (endTime != null) {
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			endTimeStr = formatter.format(endTime);
		}
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	public int getVisibility() {
		return visibility;
	}
	public void setVisibility(int visibility) {
		this.visibility = visibility;
	}

	public String getWxQRcode() {
		return wxQRcode;
	}

	public void setWxQRcode(String wxQRcode) {
		this.wxQRcode = wxQRcode;
	}

	@Transient
	public String getStartTimeStr() {
		return startTimeStr;
	}
	public void setStartTimeStr(String startTimeStr) {
		this.startTimeStr = startTimeStr;
		if (startTimeStr!=null && !startTimeStr.equals("")) {
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
			Date sdate;
			try {
				sdate = dateFormat.parse(startTimeStr);
			} catch (ParseException e) {
				sdate = null;
				e.printStackTrace();
			}
			this.startTime = sdate;
		}
	}
	@Transient
	public String getEndTimeStr() {
		return endTimeStr;
	}
	public void setEndTimeStr(String endTimeStr) {
		this.endTimeStr = endTimeStr;
		if (endTimeStr!=null && !endTimeStr.equals("")) {
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
			Date edate;
			try {
				edate = dateFormat.parse(endTimeStr);
			} catch (ParseException e) {
				edate = null;
				e.printStackTrace();
			}
			this.endTime = edate;
		}
	}
}


